package me.spring.cloud.components.starter.dlog.configuration;

import me.spring.cloud.common.components.dlog.dynamic.BootLogLevelConfig;
import me.spring.cloud.common.components.dlog.dynamic.CloudLogLevelConfig;
import me.spring.cloud.common.components.dlog.provider.SpringBootProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author luffy
 * @date 2019-04-09 13:46
 */
@Configuration
public class DlogConfiguration {

  @Bean
  public SpringBootProvider springBootProvider() {
    return new SpringBootProvider();
  }

  @Bean
  @ConditionalOnProperty(name = "logging.dynamic", havingValue = "boot")
  public BootLogLevelConfig bootLogLevelConfig() {
    return new BootLogLevelConfig();
  }

  @Bean
  @ConditionalOnProperty(name = "logging.dynamic", havingValue = "cloud")
  public CloudLogLevelConfig cloudLogLevelConfig() {
    return new CloudLogLevelConfig();
  }
}
